import sys  
import time  
import cv2  
mat_start = 0
umat_start = 0
#cap = cv2.VideoCapture("F:\\py\\camHumDetect\\img\\bd1627e63900eb94db93cab16e0cd5bc.mp4")
cap = cv2.VideoCapture("rtsp://admin:admin12345@192.168.1.230:554/h264/ch36/sub/av_stream")
while cap.isOpened():
	ret,frame = cap.read()
	# No Transparent API  
	mat_now = time.time()  
	#img = cv2.imread(cap, cv2.IMREAD_COLOR)  

	gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)  
	gray = cv2.GaussianBlur(gray, (7, 7), 1.5)  
	gray = cv2.Canny(gray, 0, 50)  
	mat_start = time.time() - mat_now + mat_start
	print('Mat costs time: %f s...' % (mat_start))  
	cv2.imshow("edges", gray)  
	  
	# Transparent API  
	umat_now = time.time()  

	imgUMat = cv2.UMat(frame)  
	ugray = cv2.cvtColor(imgUMat, cv2.COLOR_BGR2GRAY)  
	ugray = cv2.GaussianBlur(gray, (7,7), 1.5)  
	ugray = cv2.Canny(ugray, 0, 50)  
	umat_start = time.time() - umat_now + umat_start
	print('UMat costs time: %f s...' % (umat_start))  
	cv2.imshow("edges_UMat", ugray)  
	cv2.waitKey(1)  